X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=wrappers%2Fcgltrace.py;h=e7cbd7b123fa6c834e2180f04bcd769071ac2237;hb=8d1d532f4bcd04bc2855980669dc6cabec0c6415;hp=ea2267cf1c5ff1c1bb817f9a3069cbc2e3b58b55;hpb=452d3256a3ba7f249222ef857d69c8caaaa753f3;p=apitrace diff --git a/wrappers/cgltrace.py b/wrappers/cgltrace.py index ea2267c..e7cbd7b 100644 --- a/wrappers/cgltrace.py +++ b/wrappers/cgltrace.py @@ -24,7 +24,7 @@ ##########################################################################/ -"""Cgl tracing generator.""" +"""CGL tracing generator.""" from gltrace import GlTracer @@ -36,9 +36,48 @@ from specs.cglapi import cglapi class CglTracer(GlTracer): def isFunctionPublic(self, function): - # The symbols visible in libGL.dylib can vary, so expose them all + # all OpenGL symbols are visible on MacOSX return True + def traceFunctionImplBody(self, function): + if function.name == 'CGLReleaseContext': + # Unlike other GL APIs like EGL or GLX, CGL will make the context + # not current if it's the current context. + print ' if (_CGLGetContextRetainCount(ctx) == 1) {' + print ' if (gltrace::releaseContext((uintptr_t)ctx)) {' + print ' if (_CGLGetCurrentContext() == ctx) {' + print ' gltrace::clearContext();' + print ' }' + print ' }' + print ' }' + + if function.name == 'CGLDestroyContext': + # The same rule applies here about the as for CGLReleaseContext. + print ' if (gltrace::releaseContext((uintptr_t)ctx)) {' + print ' if (_CGLGetCurrentContext() == ctx) {' + print ' gltrace::clearContext();' + print ' }' + print ' }' + + GlTracer.traceFunctionImplBody(self, function) + + if function.name == 'CGLCreateContext': + print ' if (_result == kCGLNoError) {' + print ' gltrace::createContext((uintptr_t)*ctx);' + print ' }' + + if function.name == 'CGLSetCurrentContext': + print ' if (_result == kCGLNoError) {' + print ' if (ctx != NULL) {' + print ' gltrace::setContext((uintptr_t)ctx);' + print ' } else {' + print ' gltrace::clearContext();' + print ' }' + print ' }' + + if function.name == 'CGLRetainContext': + print ' gltrace::retainContext((uintptr_t)ctx);' + if __name__ == '__main__': print @@ -58,7 +97,7 @@ if __name__ == '__main__': api.addApi(cglapi) api.addApi(glapi) tracer = CglTracer() - tracer.trace_api(api) + tracer.traceApi(api) print r'''