mt trace: add helper to track GL contexts on a per-thread basis
This is needed for muti-threaded tracing to work properly.
Tracing multi-threaded GL apps requires that we track the lifetime of
the GL context objects and store thread specific state like the currently
active GL context on thread-local memory area.
Also add 'retain_count' to the context needed by the CGL retain/release
context calls.