updated to support nested clipping that optionally intersects with the previous clipping rect.