gdi: Implement line-by-line phase of the BiDi algorithm.