whenDisplayable(w, new Runnable() {
public void run() {
GDI32 gdi = GDI32.INSTANCE;
User32 user = User32.INSTANCE;
HWND hWnd = getHWnd(w);
final HRGN result = gdi.CreateRectRgn(0, 0, 0, 0);
try {
if (raster == null) {
gdi.SetRectRgn(result, 0, 0, w.getWidth(), w.getHeight());
}
else {
final HRGN tempRgn = gdi.CreateRectRgn(0, 0, 0, 0);
try {
RasterRangesUtils.outputOccupiedRanges(raster, new RasterRangesUtils.RangesOutput() {
public boolean outputRange(int x, int y, int w, int h) {
GDI32 gdi = GDI32.INSTANCE;
gdi.SetRectRgn(tempRgn, x, y, x + w, y + h);