Take this example (2 cases):

If you were drawing these rects as filled rects of the same colour, instead of drawing two whole rectangles you could optimise the number of pixels drawn to be only the total area (to avoid drawing the same pixels twice). In case 1 you would need two rectangles (a slightly shorter top one and a full size bottom one). In case2, you would need 3 vertical rectangles (I know you could do it horizontally too), I have included dotted lines to show what I mean.
Has anyone got any algorithms to do this or can you suggest a way to do it very quickly. If the algorithm is too slow there won't be any point in applying the optimisation. Also I guess this is better on bigger rectangles as if they are too small, splitting them into (up to 50%) more smaller ones could have a drawing overhead just based on more "For x/y" loops being iterated through in the drawing code.
Look forward to your ideas.

If you were drawing these rects as filled rects of the same colour, instead of drawing two whole rectangles you could optimise the number of pixels drawn to be only the total area (to avoid drawing the same pixels twice). In case 1 you would need two rectangles (a slightly shorter top one and a full size bottom one). In case2, you would need 3 vertical rectangles (I know you could do it horizontally too), I have included dotted lines to show what I mean.
Has anyone got any algorithms to do this or can you suggest a way to do it very quickly. If the algorithm is too slow there won't be any point in applying the optimisation. Also I guess this is better on bigger rectangles as if they are too small, splitting them into (up to 50%) more smaller ones could have a drawing overhead just based on more "For x/y" loops being iterated through in the drawing code.
Look forward to your ideas.