Bake-API: replacing some MEM_callocN by MEM_mallocN

As suggested and reviewed by Campbell Barton. This is the most trivial of the cases. I will look if I can do it elsewhere in the bake code
Fix T40078: GLSL Lamp with OnlyShadow makes weird colors in object.

To prevent only shadow lamps from producing negative colors, shr->diff
and shr->spec should've been clamped to positive values after lamp loop.
Fix T40438: Name of texture is not synchronize
Cleanup: Remove unused total power Emission code in Cycles, that was never exposed in the UI.

Differential Revision: https://developer.blender.org/D562
Merge remote-tracking branch 'upstream/master' into bake-cage
Fix T40445: Disabled modifiers prevent cage edit mode.

No valid reason to make non-mapping modifiers break edit cage,
when they are disabled in 3DView/edit mode!
Fix T37618 Bevel mismatched offsets and bad profile plane.

Used a different technique to resolve "impossible" offset cases
that makes more consistency. Also changed the plane in which
the profile lies for the case with only one beveled edge and
more than 3 other edges.
Fix EdgeSlide behavior with boundry edges

- would flip in opposite directions sometimes on the same loop
- some vertices would get directions from adjacent vertices
Fix incorrect flag checks for project-paint face winding
Fix uninitialized var in recent change to cursor drawing
Add debug define for timing polyfill
Cycles: Small optimization for scenes without Transparent Shaders, helps a few percent.

Differential Revision: https://developer.blender.org/D570
Code cleanup, unused variables and comments.
Fix a typo in a comment.
Fix T40315: Boolean modifier with Freestyle edges.

The helper function `make_freestyle_edge_mark_hash()` was referring to the
original mesh to determine Freestyle edge marks for individual derived mesh edges.
This is no longer necessary now that derived meshes deliver CD_FREESTYLE_EDGE
and CD_FREESTYLE_FACE layers of their own.  The reference of the original mesh
was also inappropriate since the edges coming from one of the operands of a boolean
modifier don't have proper CD_ORIGINDEX values but ORIGINDEX_NONE's.

Many thanks to Sergey Sharybin for patch contributions and discussions.
Sync changes with buildbot server
Fix T40447: Creating Rigid Bodies is rejected for meshes without polys.

This check prevents using empty (no faces) meshes as rigid bodies.
While the idea makes sense, it also prevents using modifier-constructed
meshes, where faces are added only by the modifiers.

Further the check is very easy to circumvent, by removing faces after
making the rigid body, or by assigning a different mesh datablock
afterward.

Suggested by Fabian Emmes (@der_fab).
Fix T40459: Gauss table can be NULL when ending the blur node operation,
which must not be passed to MEM_freeN.
Fix T40342 smooth shading flag in dyntopo does not work under MSVC.

Classic case of integer flag AND-ing result passed to boolean and
failing.
Freestyle: Minor fixes.

- Fixed a typo in docstring.
- Replaced int with boolean constants.
- Updated lists of base classes for used-defined unary 0D/1D functions.