gdi32: Move some common code out of the individual copy_rect functions.