Win32 Bug: GDI.SetROP2(R2_MASKPEN) causes garbled output on window resize


I’ve made a very simple program that demostrates the bug. Basically painting with raster operations other than R2_COPYPUT produces garbled output if window is resized or moved back from off-screen area. Here’s source code and video:

I’ve tried the same program on non-NVIDIA chipsets and all is just fine.