Fix T40761: Bone constraints broken in the BGE

Extra bonus: calculating bone constraints now happens parallel!
Python: remove redundant casts
Fix T40065: Pressing Esc in separate render result window does not focus main window.

The problem is that the render window keeps keybord input focus even after it has been
lowered. Windows maintains the Z-order of windows, so the present solution is to raise
the window that has been just below the render window.

Differential revision: https://developer.blender.org/D594
Reviewed by: campbellbarton
Code cleanup: use enum for setup_app_data
Fix strict flags compilation
Fix T40895: Curves panel, zooming out a lot crashes Blender
Correct enum size incase compiler makes enum signed
Code cleanup: use scene variable rather then calling CTX_data_scene
Fix T40888: Memory error when selecting Cycles render engine
Fix T40556: Curve Modifier does not work when used in a Background scene

A bit hackish solution for now, cleaner solution we'll look into as a
part of the new DAG project, when it's clear what kind of data is passed
to the evaluation callbacks.
Second attempt to fix T40833: Crash when rendering with freestyle.

The cause of the crash was identified in an uninitialized member variable
`Main->lock`.  Now that struct Main has a few member variables whose
values are dynamically allocated, per-render Freestyle-specific Main data
structures will be allocated and released using `BKE_main_new()` and
`BKE_main_free()`, respectively.

This revision complements the commit rB6135556f4556.
Fix T40903: Rendering: Alpha Channel is Broken
Fix for segmentation fault in pipeline (freestyle/wm related)
Fix T40257: Frustum culling not working properly

Adding a hack so that KX_GameObjects' culling status is updated based on
mesh slots.
Cleanup: Update list and remove ifdef here.
Cleanup: Remove unused checks in CUDA device code.
Cycles: Update CUDA error messages, based on Toolkit 6.0.

* Removed deprecated erros, and added some new ones, which might help to figure out problems in the future.
Added missing G_DEBUG_DEPSGRAPH flag entry in the bpy.app.debug getters/setters list.
Fix T40364: Texture images are not properly displayed in the material preview in BI when using SSS

Blender Internal only uses materials with non-zero user counter for SSS and new
mutable libblock copy was keeping users counter at zero.

Now it sets user counter to 1, which is a bit of arguable decision, but which
also kind of makes sense -- meaning callee owns the copied block.
Fix T40815: Particle birth times not initialized correctly.

In rB78c491e the `initialize_particle` function was split into 2 parts for particle texture initialization.
The texture init part however also initializes birth times, which is now missing in the main init function
in some cases (notably when setting start/end directly without a subsequent time step).