When a gradient has no stop at offset 0 or 255, the drawing code will
not automatically complete the gradiet with the first or last color,
instead agg interpolation generated invalid random colors.
To avoid this, insert extra stops at the start and end in the
DrawingEngine when we prepare the gradient for drawing. We just copy the
first and last stops to new stops at offsets 0 and 255, which makes sure
the gradients covers the whole range and gives the expected result.
Fixes#2945.