]> git.cworth.org Git - apitrace/blobdiff - egltrace.py
Move local writer definitions to a separate header file.
[apitrace] / egltrace.py
index 64e51910300782c4e4d08e7360585b1f7d17ebf1..8fa313a2117b37a5d4c4298b62fbffa90f6a7b59 100644 (file)
@@ -35,6 +35,7 @@
 from specs.stdapi import API
 from specs.glapi import glapi
 from specs.eglapi import eglapi
+from specs.glesapi import glesapi
 from gltrace import GlTracer
 from dispatch import function_pointer_type, function_pointer_value
 
@@ -48,18 +49,19 @@ class EglTracer(GlTracer):
     def trace_function_impl_body(self, function):
         GlTracer.trace_function_impl_body(self, function)
 
-        # Take snapshots
-        if function.name == 'eglSwapBuffers':
-            print '    glsnapshot::snapshot(__call);'
-        if function.name in ('glFinish', 'glFlush'):
-            print '    GLint __draw_framebuffer = 0;'
-            print '    __glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &__draw_framebuffer);'
-            print '    if (__draw_framebuffer == 0) {'
-            print '        GLint __draw_buffer = GL_NONE;'
-            print '        __glGetIntegerv(GL_DRAW_BUFFER, &__draw_buffer);'
-            print '        if (__draw_buffer == GL_FRONT) {'
-            print '             glsnapshot::snapshot(__call);'
-            print '        }'
+        if function.name == 'eglMakeCurrent':
+            print '    // update the profile'
+            print '    if (ctx != EGL_NO_CONTEXT) {'
+            print '        EGLint api = EGL_OPENGL_ES_API, version = 1;'
+            print '        tracer_context *tr = __get_context();'
+            print '        __eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_TYPE, &api);'
+            print '        __eglQueryContext(dpy, ctx, EGL_CONTEXT_CLIENT_VERSION, &version);'
+            print '        if (api == EGL_OPENGL_API)'
+            print '            tr->profile = PROFILE_COMPAT;'
+            print '        else if (version == 1)'
+            print '            tr->profile = PROFILE_ES1;'
+            print '        else'
+            print '            tr->profile = PROFILE_ES2;'
             print '    }'
 
     def wrap_ret(self, function, instance):
@@ -74,7 +76,7 @@ if __name__ == '__main__':
     print '#include <string.h>'
     print '#include <dlfcn.h>'
     print
-    print '#include "trace_writer.hpp"'
+    print '#include "trace_writer_local.hpp"'
     print
     print '// To validate our prototypes'
     print '#define GL_GLEXT_PROTOTYPES'
@@ -82,7 +84,6 @@ if __name__ == '__main__':
     print
     print '#include "glproc.hpp"'
     print '#include "glsize.hpp"'
-    print '#include "glsnapshot.hpp"'
     print
     print 'static __eglMustCastToProperFunctionPointerType __unwrap_proc_addr(const char * procname, __eglMustCastToProperFunctionPointerType procPtr);'
     print
@@ -90,6 +91,7 @@ if __name__ == '__main__':
     api = API()
     api.add_api(eglapi)
     api.add_api(glapi)
+    api.add_api(glesapi)
     tracer = EglTracer()
     tracer.trace_api(api)
 
@@ -108,30 +110,3 @@ if __name__ == '__main__':
     print '    return procPtr;'
     print '}'
     print
-    print r'''
-
-/*
- * Lookup a EGL or GLES symbol
- */
-void * __libegl_sym(const char *symbol, bool pub)
-{
-    void *proc;
-
-    /*
-     * Public symbols are EGL core functions and those defined in dekstop GL
-     * ABI.  Troubles come from the latter.
-     */
-    if (pub) {
-        proc = dlsym(RTLD_NEXT, symbol);
-        if (!proc && symbol[0] == 'g' && symbol[1] == 'l')
-            proc = (void *) __eglGetProcAddress(symbol);
-    }
-    else {
-        proc = (void *) __eglGetProcAddress(symbol);
-        if (!proc && symbol[0] == 'g' && symbol[1] == 'l')
-            proc = dlsym(RTLD_NEXT, symbol);
-    }
-
-    return proc;
-}
-'''