mt trace: create gltrace_state.cpp, move getContext into it

There is no need to keep this function in a python script and the
following patches will extend the functionality around this code, so
move the function to a .cpp file.

Signed-off-by: Imre Deak <imre.deak@intel.com>
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.

Needed by the 4 upcoming GL API specific patches.

Signed-off-by: Imre Deak <imre.deak@intel.com>
mt trace: cgl: track GL context on a per-thread basis

Wrap CGL context handling calls and keep our own per-thread basis track
of the context object.

Signed-off-by: Imre Deak <imre.deak@intel.com>
check for error in eglMakeCurrent wrapper

In case of error we shouldn't update our book-keeping.

Signed-off-by: Imre Deak <imre.deak@intel.com>
mt trace: egl: track GL context on a per-thread basis

Wrap EGL context handling calls and keep our own per-thread basis track
of the context object.

Signed-off-by: Imre Deak <imre.deak@intel.com>
mt trace: glx: track GL context on a per-thread basis

Wrap GLX context handling calls and keep our own per-thread basis track
of the context object.

Signed-off-by: Imre Deak <imre.deak@intel.com>
mt trace: wgl: track GL context on a per-thread basis

Wrap WGL context handling calls and keep our own per-thread basis track
of the context object.

Signed-off-by: Imre Deak <imre.deak@intel.com>
gui: new checkbox to visualize alpha channel of image
gui: remove a depth check box that sneak into alpha code
gui: Fix editing of the shaders

Editing shaders was broken because we were adding extra values to
the arguments array. This fixes it, meaning that if you right click
on glShaderSource you can edit the shader source and the rest of the
trace will properly catch the changes. An incredibly useful feature.
glsl edit: grep multiline error/warning messages

Useful for GL shader errors which spawn multiple lines error message like that:
    >> 2135: warning: Vertex shader failed to compile with the following errors:
    >> ERROR: 1:1: error(#132) Syntax error: 'sdfsafasf' parse error
    >> ERROR: error(#273) 1 compilation errors.  No code generated
Merge pull request #87 from gregory38/multiple-line-errors

glsl edit: grep multiline error/warning messages
Merge pull request #88 from gregory38/image-alpha-channel-I84-v2

Image alpha channel i84 v2
Android: add support for dynamically enable/disable tracing

To trace applications started by the Dalvik VM we have to wrap the main
Dalvik process zygote (or app_process) which is started at boot time and
never stopped afterwards. We would still want to restrict tracing to a
single process which will be forked by zygote.

To achieve this we'll use the fact that the forked process image is
contained in the same file as zygote, pointed to by /proc/self/exe. So
if this is 'app_process' we know it's a zygote process. To distinguish
between zygote processes we'll check /proc/self/cmdline which will in
turn be set to a unique application specific string (for example
com.android.settings). The user has to set the debug.apitrace.procname
to this string in order to enable tracing.

For non-zygote processes tracing will be always enabled.

Signed-off-by: Imre Deak <imre.deak@intel.com>
Android: add usage instructions for tracing zygote applications

Signed-off-by: Imre Deak <imre.deak@intel.com>
Relocate tracing (dis/en)enablement.

Out of common -- as it is tracing specific
Fix build. Add copyright header to new files.
Fix CGL.
Fix wglDeleteContext tracing.

wglGetCurrentContext must be called before.
Fix build on MSVC.