static void ReverseSubpathAndAdjustFlags(int start, int end, List<byte> old_types, List<byte> new_types, ref bool isPrevHadMarker)
{
// Copy all but PathPointTypeStart
if (end != start)
new_types.AddRange (old_types.GetRange (start + 1, end - start));
// Append PathPointTypeStart
new_types.Add ((byte)PathPointType.Start);
Debug.Assert (new_types.Count == end + 1);
var prev_first = old_types [start];
var prev_last = old_types [end];
// Remove potential flags from our future start point
if (end != start)
new_types[end - 1] &= (byte)PathPointType.PathTypeMask;
// Set the flags on our to-be-last point
if ((prev_last & (byte)PathPointType.DashMode) != 0)
new_types[start] |= (byte)PathPointType.DashMode;
if ((prev_last & (byte)PathPointType.CloseSubpath) != 0)
new_types[start] |= (byte)PathPointType.CloseSubpath;
//
// Swap markers
//
for (int i = start + 1; i < end; i++) {
if ((old_types [i - 1] & (byte)PathPointType.PathMarker) != 0)
new_types [i] |= (byte)PathPointType.PathMarker;
else
//new_types[i] &= ~PathPointType.PathMarker;
// Can not take compliment for negative numbers so we XOR
new_types [i] &= ((byte)PathPointType.PathMarker ^ 0xff);
}
// If the last point of the previous subpath had a marker, we inherit it
if (isPrevHadMarker)
new_types[start] |= (byte)PathPointType.PathMarker;
else
//new_types[start] &= ~PathPointType.PathMarker;
// Can not take compliment for negative numbers so we XOR
new_types[start] &= ((byte)PathPointType.PathMarker ^ 0xff);
isPrevHadMarker = ((prev_last & (byte)PathPointType.PathMarker) == (byte)PathPointType.PathMarker);
}