If the color fill opacity is equal to 1.0, it's very hard to see the strokes that you want to fill. With this change, always the stroke is visible while painting.
The problem was if the layer below had animation in frames not present in top layer. As the active frame of top layer was the previous keyframe, after merging, the draw of bottom layer replaced the draw of top layer and the result was that some drawings were missing.
The solution was to duplicate the active frame in top layer before merge the bottom layer.
* Only initialise the falloff curve's internal data once per run, instead of once per layer. We can probably even make this only happen once for each run of the operator, as it shouldn't be possible to change the curve in the meantime (requiring the data to be recalculated)
* Save off the multiframe falloff option into a variable instead of doing the full check each time.
* Only calculate "diff_mat" once for each layer, instead of once for each GP frame for multiedit. (Note: We weren't taking the frame numbers into account anyway, so it doesn't matter to pull this out. However, technically, if the layer was parented, we'd actually need to have been recalculating the parents transforms for each of the multiedit frames to get the real intended effects)