=== modified file 'src/composite-canvas-egl.cc'
--- src/composite-canvas-egl.cc	2011-07-15 13:01:34 +0000
+++ src/composite-canvas-egl.cc	2011-12-12 13:16:47 +0000
@@ -19,6 +19,7 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #include <string>
@@ -26,9 +27,13 @@
 
 #include "gl-headers.h"
 
+#ifdef USE_GLPROXY
+#include <EGL/egl_proxy.h>
+#include <EGL/eglext_proxy.h>
+#else
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
-
+#endif
 #include "composite-canvas-egl.h"
 #include "composite-window-eglimage.h"
 #include "composite-window-ximage.h"
@@ -37,6 +42,9 @@
 
 PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR_;
 PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR_;
+#ifdef USE_GLPROXY
+typedef PFNPROXYEGLIMAGETARGETTEXTURE2DOESPROC PFNGLEGLIMAGETARGETTEXTURE2DOESPROC;
+#endif
 PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_;
 
 bool
@@ -119,11 +127,7 @@
         EGL_BLUE_SIZE, 1,
         EGL_ALPHA_SIZE, 1,
         EGL_DEPTH_SIZE, 1,
-#ifdef USE_GLES2
-        EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-#elif USE_GL
-        EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
-#endif
+        EGL_RENDERABLE_TYPE, Options::backend == Options::BACKEND_EGL_GL? EGL_OPENGL_BIT : EGL_OPENGL_ES2_BIT,
         EGL_NONE
     };
     EGLint num_configs;
@@ -161,12 +165,14 @@
 bool
 CompositeCanvasEGL::ensure_egl_surface()
 {
-    static const EGLint ctx_attribs[] = {
-#ifdef USE_GLES2
-        EGL_CONTEXT_CLIENT_VERSION, 2,
-#endif
-        EGL_NONE
-    };
+    EGLint ctx_attribs[3];
+    if (Options::backend == Options::BACKEND_EGL_ES2) {
+        ctx_attribs[0] = EGL_CONTEXT_CLIENT_VERSION;
+        ctx_attribs[1] = 2;
+        ctx_attribs[2] = EGL_NONE;
+    } else {
+        ctx_attribs[0] = EGL_NONE;
+    }
 
     if (egl_surface_)
         return true;
@@ -174,11 +180,10 @@
     if (!ensure_egl_display())
         return false;
 
-#ifdef USE_GLES2
-    eglBindAPI(EGL_OPENGL_ES_API);
-#elif USE_GL
-    eglBindAPI(EGL_OPENGL_API);
-#endif
+    if (Options::backend == Options::BACKEND_EGL_GL)
+        eglBindAPI(EGL_OPENGL_API);
+    else
+        eglBindAPI(EGL_OPENGL_ES_API);
 
     egl_context_ = eglCreateContext(egl_display_, egl_config_,
                                     EGL_NO_CONTEXT, ctx_attribs);

=== modified file 'src/composite-canvas-egl.h'
--- src/composite-canvas-egl.h	2011-07-15 13:01:34 +0000
+++ src/composite-canvas-egl.h	2011-12-09 16:09:11 +0000
@@ -19,12 +19,17 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #ifndef COMPOSITE_CANVAS_EGL_H_
 #define COMPOSITE_CANVAS_EGL_H_
 
+#ifdef USE_GLPROXY
+#include <EGL/egl_proxy.h>
+#else
 #include <EGL/egl.h>
+#endif
 #include "composite-canvas.h"
 
 class CompositeCanvasEGL: public CompositeCanvas

=== modified file 'src/composite-canvas-glx.cc'
--- src/composite-canvas-glx.cc	2011-07-19 21:34:08 +0000
+++ src/composite-canvas-glx.cc	2011-12-09 16:09:11 +0000
@@ -19,13 +19,19 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #include <string>
 #include <sstream>
 
-#include <GL/gl.h>
+#include "gl-headers.h"
+#ifdef USE_GLPROXY
+#include <GL/glx_proxy.h>
+#include <GL/glxext_proxy.h>
+#else
 #include <GL/glx.h>
+#endif
 
 #include "composite-canvas-glx.h"
 #include "composite-window-glxpixmap.h"
@@ -33,11 +39,19 @@
 #include "options.h"
 #include "log.h"
 
+#ifdef USE_GLPROXY
+// NOTE: This is necessary because glproxy names these typedefs differently.
+typedef PFNPROXYBINDTEXIMAGEEXTPROC PFNGLXBINDTEXIMAGEEXTPROC;
+typedef PFNPROXYRELEASETEXIMAGEEXTPROC PFNGLXRELEASETEXIMAGEEXTPROC;
+typedef PFNPROXYSWAPINTERVALEXTPROC PFNGLXSWAPINTERVALEXTPROC;
+typedef PFNPROXYSWAPINTERVALMESAPROC PFNGLXSWAPINTERVALMESAPROC;
+#endif
 PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT_;
 PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT_;
 PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT_;
 PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA_;
 
+
 bool
 CompositeCanvasGLX::check_glx_version()
 {

=== modified file 'src/composite-canvas-glx.h'
--- src/composite-canvas-glx.h	2011-07-15 13:01:34 +0000
+++ src/composite-canvas-glx.h	2011-12-09 16:09:11 +0000
@@ -19,12 +19,17 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #ifndef COMPOSITE_CANVAS_GLX_H_
 #define COMPOSITE_CANVAS_GLX_H_
 
+#ifdef USE_GLPROXY
+#include <GL/glx_proxy.h>
+#else
 #include <GL/glx.h>
+#endif
 #include "composite-canvas.h"
 
 class CompositeCanvasGLX: public CompositeCanvas

=== modified file 'src/composite-window-eglimage.cc'
--- src/composite-window-eglimage.cc	2011-08-03 14:34:10 +0000
+++ src/composite-window-eglimage.cc	2011-12-09 16:09:11 +0000
@@ -19,21 +19,31 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #include <X11/Xlib.h>
 
 #include "gl-headers.h"
 
+#ifdef USE_GLPROXY
+#include <EGL/egl_proxy.h>
+#include <EGL/eglext_proxy.h>
+#else
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
+#endif
 
 #include "composite-window-eglimage.h"
 #include "log.h"
 
 extern PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR_;
 extern PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR_;
+#ifdef USE_GLPROXY
+extern PFNPROXYEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_;
+#else
 extern PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES_;
+#endif
 
 CompositeWindowEGLImage::~CompositeWindowEGLImage()
 {

=== modified file 'src/composite-window-eglimage.h'
--- src/composite-window-eglimage.h	2011-08-03 14:34:10 +0000
+++ src/composite-window-eglimage.h	2011-12-09 16:09:11 +0000
@@ -19,6 +19,7 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #ifndef COMPOSITE_WINDOW_EGLIMAGE_H_
@@ -26,8 +27,13 @@
 
 #include <X11/Xlib.h>
 #include "gl-headers.h"
+#ifdef USE_GLPROXY
+#include <EGL/egl_proxy.h>
+#include <EGL/eglext_proxy.h>
+#else
 #include <EGL/egl.h>
 #include <EGL/eglext.h>
+#endif
 #include "composite-window-gl.h"
 
 class CompositeWindowEGLImage : public CompositeWindowGL

=== modified file 'src/composite-window-glxpixmap.cc'
--- src/composite-window-glxpixmap.cc	2011-08-03 14:34:10 +0000
+++ src/composite-window-glxpixmap.cc	2011-12-09 16:09:11 +0000
@@ -19,20 +19,32 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #include <X11/Xlib.h>
 
+#include "gl-headers.h"
+
+#ifdef USE_GLPROXY
+#include <GL/glx_proxy.h>
+#include <GL/glxext_proxy.h>
+#else
 #define GLX_GLXEXT_PROTOTYPES
-#include <GL/gl.h>
 #include <GL/glx.h>
 #include <GL/glxext.h>
+#endif
 
 #include "composite-window-glxpixmap.h"
 #include "log.h"
 
+#ifdef USE_GLPROXY
+extern PFNPROXYBINDTEXIMAGEEXTPROC glXBindTexImageEXT_;
+extern PFNPROXYRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT_;
+#else
 extern PFNGLXBINDTEXIMAGEEXTPROC glXBindTexImageEXT_;
 extern PFNGLXRELEASETEXIMAGEEXTPROC glXReleaseTexImageEXT_;
+#endif
 
 void
 CompositeWindowGLXPixmap::release_tfp()

=== modified file 'src/composite-window-glxpixmap.h'
--- src/composite-window-glxpixmap.h	2011-08-03 14:34:10 +0000
+++ src/composite-window-glxpixmap.h	2011-12-09 16:09:11 +0000
@@ -19,13 +19,18 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #ifndef COMPOSITE_WINDOW_GLXPIXMAP_H_
 #define COMPOSITE_WINDOW_GLXPIXMAP_H_
 
 #include <X11/Xlib.h>
+#ifdef USE_GLPROXY
+#include <GL/glx_proxy.h>
+#else
 #include <GL/glx.h>
+#endif
 #include "composite-window-gl.h"
 
 class CompositeWindowGLXPixmap : public CompositeWindowGL

=== modified file 'src/gl-headers.h'
--- src/gl-headers.h	2011-02-07 18:35:50 +0000
+++ src/gl-headers.h	2011-12-09 16:09:11 +0000
@@ -19,11 +19,17 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #ifndef GL_HEADERS_H_
 #define GL_HEADERS_H_
 
+#ifdef USE_GLPROXY
+#include <GL/gl_proxy.h>
+#include <GL/glext_proxy.h>
+#else
+
 #ifdef USE_GL
 #define GL_GLEXT_PROTOTYPES
 #include <GL/gl.h>
@@ -33,4 +39,6 @@
 #include <GLES2/gl2ext.h>
 #endif
 
+#endif // USE_GLPROXY
+
 #endif /* GL_HEADERS_H_ */

=== modified file 'src/glcompbench.cc'
--- src/glcompbench.cc	2011-10-13 22:48:52 +0000
+++ src/glcompbench.cc	2011-12-12 13:16:47 +0000
@@ -19,13 +19,18 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #include <list>
 
+#ifdef USE_GLPROXY
+#include <GL/gl_proxy.h>
+#endif
 #ifdef USE_EGL
 #include "composite-canvas-egl.h"
-#elif USE_GLX
+#endif
+#if USE_GLX
 #include "composite-canvas-glx.h"
 #endif
 #include "composite-canvas-pixman.h"
@@ -140,22 +145,42 @@
     canvas_list.push_back(new CompositeCanvasPixman());
     canvas_list.push_back(new CompositeCanvasXRender());
 
+    if (!Options::parse_args(argc, argv))
+        return 1;
+
+    if (Options::show_help ||
+        Options::backend == Options::BACKEND_NONE) {
+        Options::print_help();
+        return 0;
+    }
+
+#ifdef USE_GLPROXY
+    // Initialize the proxy library and create the correct GL canvas
+    PROXY_BACKEND_OPTION backend = UNKNOWN_BACKEND;
+    if (Options::backend == Options::BACKEND_GLX) {
+        backend = OPENGL_BACKEND;
+        glProxyInit(&backend);
+
+        canvas_list.push_back(new CompositeCanvasGLX());
+    } else if (Options::backend == Options::BACKEND_EGL_ES2) {
+        backend = OPENGL_ES20_BACKEND;
+        glProxyInit(&backend);
+
+        canvas_list.push_back(new CompositeCanvasEGL());
+    } else {
+        Options::print_help();
+        return 0;
+    }
+#else // USE_GLPROXY
 #ifdef USE_EGL
     canvas_list.push_back(new CompositeCanvasEGL());
 #elif USE_GLX
     canvas_list.push_back(new CompositeCanvasGLX());
 #endif
+#endif // USE_GLPROXY
 
     std::list<Benchmark*> benchmarks;
 
-    if (!Options::parse_args(argc, argv))
-        return 1;
-
-    if (Options::show_help) {
-        Options::print_help();
-        return 0;
-    }
-
     Benchmark::register_test(*new CompositeTestDefaultOptions());
     Benchmark::register_test(*new CompositeTestSimpleDefault());
     Benchmark::register_test(*new CompositeTestSimpleFade());

=== modified file 'src/options.cc'
--- src/options.cc	2011-06-24 13:44:02 +0000
+++ src/options.cc	2011-12-12 13:16:47 +0000
@@ -19,6 +19,7 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #include <X11/Xlib.h>
@@ -42,6 +43,15 @@
 bool Options::show_help = false;
 bool Options::list_tests = false;
 bool Options::swap_buffers = true;
+#ifdef USE_GLPROXY
+Options::Backends Options::backend = BACKEND_EGL_ES2;
+#elif defined(USE_GLX)
+Options::Backends Options::backend = BACKEND_GLX;
+#elif defined(USE_EGL) && defined(USE_GL)
+Options::Backends Options::backend = BACKEND_EGL_GL;
+#elif defined(USE_EGL) && defined(USE_GLES2)
+Options::Backends Options::backend = BACKEND_EGL_ES2;
+#endif
 
 static struct option long_options[] = {
     {"ids", 1, 0, 0},
@@ -57,9 +67,22 @@
     {"no-swap-buffers", 0, 0, 0},
     {"debug", 0, 0, 0},
     {"help", 0, 0, 0},
+    {"backend", 1, 0, 0},
     {0, 0, 0, 0}
 };
 
+#ifdef USE_GLPROXY
+static const char *available_backends = "glx, egl-es2";
+#elif defined(USE_GLX)
+static const char *available_backends = "glx";
+#elif defined(USE_EGL) && defined(USE_GL)
+static const char *available_backends = "egl-gl";
+#elif defined(USE_EGL) && defined(USE_GLES2)
+static const char *available_backends = "egl-es2";
+#else
+static const char *available_backends = "";
+#endif
+
 static void
 parse_window_ids(const char *str, std::list<Window> &list)
 {
@@ -74,6 +97,22 @@
     }
 }
 
+static Options::Backends
+parse_backend(const char *str)
+{
+    if (!strstr(available_backends, str))
+        return Options::BACKEND_NONE;
+
+    if (!strcmp("glx", str))
+        return Options::BACKEND_GLX;
+    else if (!strcmp("egl-gl", str))
+        return Options::BACKEND_EGL_GL;
+    else if (!strcmp("egl-es2", str))
+        return Options::BACKEND_EGL_ES2;
+
+    return Options::BACKEND_NONE;
+}
+
 void
 Options::print_help()
 {
@@ -95,8 +134,10 @@
            "  -l, --list-tests       List the avalaible tests and their options\n"
            "      --no-swap-buffers  Don't update the screen by swapping the front and\n"
            "                         back buffer, use glFinish() instead\n"
+           "      --backend          The OpenGL backend to use (%s)\n"
            "  -d, --debug            Display debug messages\n"
-           "  -h, --help             Display help\n");
+           "  -h, --help             Display help\n",
+           available_backends);
 }
 
 bool
@@ -143,6 +184,8 @@
             Options::show_debug = true;
         else if (c == 'h' || !strcmp(optname, "help"))
             Options::show_help = true;
+        else if (!strcmp(optname, "backend"))
+            Options::backend = parse_backend(optarg);
     }
 
     return true;

=== modified file 'src/options.h'
--- src/options.h	2011-06-23 13:32:36 +0000
+++ src/options.h	2011-12-12 13:16:47 +0000
@@ -19,6 +19,7 @@
  * Authors:
  *  Alexandros Frantzis <alexandros.frantzis@linaro.org>
  *  Jesse Barker <jesse.barker@linaro.org>
+ *  Marc Ordinas i Llopis, Collabora Ltd <marc.ordinasillopis@linaro.org>
  */
 
 #ifndef OPTIONS_H_
@@ -45,6 +46,14 @@
     static bool show_help;
     static bool list_tests;
     static bool swap_buffers;
+
+    typedef enum {
+        BACKEND_NONE,
+        BACKEND_GLX,
+        BACKEND_EGL_GL,
+        BACKEND_EGL_ES2
+    } Backends;
+    static Backends backend;
 };
 
 #endif /* OPTIONS_H_ */

=== modified file 'src/wscript_build'
--- src/wscript_build	2011-08-03 17:03:48 +0000
+++ src/wscript_build	2011-12-12 13:18:23 +0000
@@ -8,6 +8,7 @@
 
 common_libs = ['x11', 'xdamage', 'xcomposite', 'pixman', 'xext', 'xrender']
 
+# libmatrix
 if bld.env.BUILD_EGL_GL or bld.env.BUILD_GLX:
     bld(
         features = ['cxx', 'cxxstlib'],
@@ -30,6 +31,18 @@
         export_includes = 'libmatrix'
         )
 
+if bld.env.BUILD_GLPROXY:
+    bld(
+        features = ['cxx', 'cxxstlib'],
+        source   = bld.path.ant_glob('libmatrix/*.cc'),
+        target   = 'matrix-glproxy',
+        lib      = ['m'],
+        includes = ['.'],
+        defines  = ['USE_GLPROXY'],
+        export_includes = 'libmatrix'
+        )
+
+# glcompbench
 if bld.env.BUILD_EGL_GL:
     bld(
         features = ['cxx', 'cprogram'],
@@ -63,4 +76,15 @@
         defines  = ['USE_GLX', 'USE_GL']
         )
 
+if bld.env.BUILD_GLPROXY:
+    bld(
+        features = ['cxx', 'cprogram'],
+        source   = common_sources + egl_sources + glx_sources,
+        target   = 'glcompbench',
+        uselib   = ['glproxy'] + common_libs,
+        use      = ['matrix-glproxy'],
+        lib      = ['m'],
+        defines  = ['USE_EGL', 'USE_GLES2', 'USE_GLX', 'USE_GL', 'USE_GLPROXY']
+        )
+
 bld.install_files('${PREFIX}/bin', ['gl-composite-benchmark'], chmod=0755)

=== modified file 'wscript'
--- wscript	2011-10-17 14:15:32 +0000
+++ wscript	2011-12-09 16:09:11 +0000
@@ -22,7 +22,7 @@
     opt.add_option('--with-flavors', type = 'string', action='callback',
                    callback=option_list_cb,
                    dest = 'flavors',
-                   help = "a list of flavors to build (glx, egl-gl, egl-es2, all)")
+                   help = "a list of flavors to build (glx, egl-gl, egl-es2, glproxy, all)")
     opt.parser.set_default('flavors', ['egl-es2'])
 
 def configure(ctx):
@@ -33,16 +33,17 @@
     # Special 'all' flavor
     if 'all' in Options.options.flavors:
         Options.options.flavors.remove('all')
-        Options.options.flavors |= set(['glx', 'egl-gl', 'egl-es2'])
+        Options.options.flavors |= set(['glx', 'egl-gl', 'egl-es2', 'glproxy'])
 
     # Ensure the flavors are valid
     for flavor in Options.options.flavors:
-        if flavor not in ('glx', 'egl-es2', 'egl-gl'):
-            ctx.fatal('Unknown flavor: %s. Supported flavors are glx, egl-gl and egl-es2' % flavor)
+        if flavor not in ('glx', 'egl-es2', 'egl-gl', 'glproxy'):
+            ctx.fatal('Unknown flavor: %s. Supported flavors are glx, egl-gl, egl-es2 and glproxy' % flavor)
 
     ctx.env.BUILD_GLX = 'glx' in Options.options.flavors
     ctx.env.BUILD_EGL_ES2 = 'egl-es2' in Options.options.flavors
     ctx.env.BUILD_EGL_GL = 'egl-gl' in Options.options.flavors
+    ctx.env.BUILD_GLPROXY = 'glproxy' in Options.options.flavors
 
     # Check required headers
     req_headers = ['inttypes.h', 'stdint.h', 'sys/time.h']
@@ -71,7 +72,8 @@
     # Check conditional packages
     req_pkgs = [('egl', 'egl', ctx.env.BUILD_EGL_ES2 or ctx.env.BUILD_EGL_GL),
                 ('glesv2', 'glesv2', ctx.env.BUILD_EGL_ES2),
-                ('gl', 'gl', ctx.env.BUILD_GLX or ctx.env.BUILD_EGL_GL)]
+                ('gl', 'gl', ctx.env.BUILD_GLX or ctx.env.BUILD_EGL_GL),
+                ('glproxy', 'glproxy', ctx.env.BUILD_GLPROXY)]
     for (pkg, uselib, check_for) in req_pkgs:
         if check_for:
             ctx.check_cfg(package = pkg, uselib_store = uselib, args = '--cflags --libs',

