Minor cleanup of previous commit.
Fix T40299, Crash on rendering due to dependency cycles and NULL pointer when using particle duplis.
Bake API: partial fix T40156 (applyRotation issues)

This fixes most of the cases, the only situation not addressed is when
the highpoly object(s) has non-uniform scale.

mul_transposed_mat3_m4_v3() should take care of non-uniform scales so
I'm a bit confused on why it doesn't work. The lowpoly object can have
any transformation, the only issue is if the highpoly object has
non-uniform scale.

Test file of the remaining issue:
https://developer.blender.org/file/info/PHID-FILE-tpw2xgddyzxtpg3e7xzs/

Reference reading:
http://www.unknownroad.com/rtfm/graphics/rt_normals.html
Fix T40297: Crash while ripping an edge when autosmooth is activated.

Turned out there was still quite a few cases were indices were set dirty,
but elem_index_dirty was not tagged accordingly (mostly for BM_LOOP,
but a few others as well). So probably this crash was not the only one
hidden here.

Hopefully all possible cases were catched this time!
Fix T40283: Matcaps disables GLSL shadows
Fix for image garbage collection failing to run for render-only views

Check for freeing old images was running per-object, move this to viewport drawing.
Bugfix T40292: Trying to rename shapekey datablocks from AnimEditors renamed object instead
Fix T40304: Rearranging NLA Tracks (and actually, all animation channels) didn't work anymore

These were broken by 1f3655d224196129fc6daf20e678199b95321bff, since
an argument of the wrong type was getting passed to ANIM_animdata_filter(),
resulting in no channels ever being picked up for the "visible channels" list.
Previous commit uncovered another bug - Ungrouped FCurves couldn't be rearranged still

This was because to the filtering code, those FCurves still weren't in any
groups, and so couldn't be visible (since a temporary group is created to
house them). As a result, the visible-channels list would be empty, causing
all hidden FCurves to be treated as hidden.
Code cleanup - Reshuffling some defines
For increased type safety, ANIM_animdata_filter() now specifies the enums its arguments can use

Hopefully this should help prevent bugs lik T40304 from occurring again.
Fix T40309: Select inner region 'bigger' failed with equal regions
Fix T40215: Boolean looses bevel width
Freestyle: Fix for versioning code not working properly with new texture options.

To get the versioning code properly work, the condition should have been:

  DNA_struct_elem_find(fd->filesdna, "FreestyleLineStyle", "MTex", "*mtex[18]")

The present commit uses another new structure member instead, to avoid referring
to the magic number 18 in the last string literal.
Freestyle: added missing forward declarations of referenced struct's.
Fix T38493: ray_cast causes runtime error with no faces
Mistake naming in recent commit
Don't write all uv textures, but only active uv layer.

Fix T39922
PackedFiles: add (readonly for now) access to packed raw data (most useful for exporters).
Correction to previous commit, sorry about that. :/