多次调用NSView -draw方法

时间:2017-11-29 23:14:32

标签: cocoa nsview appkit

我有NSScrollView嵌入式NSClipViewNSView。没什么特别的。但是当我将NSScrollView.magnification更改为大于小的东西时,NSView.draw(_ dirtyRect:NSRect)会从某个地方多次调用。 仅magnification = 0.2 -draw被调用一次:

refresh 20.0%
visible rect: (-2634.99999999952, -812.500000000788, 5769.99999999869, 2625.00000000089)
drawing... (-250.0, -500.0, 1000.0, 2000.0)

refresh = magnification * 100

visible rect: - 取自NSClipView.documentVisibleRect

drawing... - 在dirtyRect方法

的开头打印-draw

表示.magnification = 1.0 - 六次:

refresh 100.0%
visible rect: (-327.0, 237.5, 1154.0, 525.0)
drawing... (0.0, 0.0, 750.0, 1024.0)
drawing... (-250.0, 0.0, 250.0, 1024.0)
drawing... (-250.0, -500.0, 250.0, 500.0)
drawing... (0.0, -500.0, 750.0, 500.0)
drawing... (-250.0, 1024.0, 250.0, 476.0)
drawing... (0.0, 1024.0, 750.0, 476.0)

for 2.0 ...难以计算:

refresh 200.0%
visible rect: (-38.5, 368.75, 577.0, 262.5)
drawing... (384.0, 256.0, 128.0, 128.0)
drawing... (256.0, 512.0, 128.0, 128.0)
drawing... (0.0, 256.0, 128.0, 128.0)
drawing... (512.0, 384.0, 128.0, 128.0)
drawing... (384.0, 512.0, 128.0, 128.0)
drawing... (128.0, 256.0, 128.0, 128.0)
drawing... (-128.0, 384.0, 128.0, 128.0)
drawing... (0.0, 512.0, 128.0, 128.0)
drawing... (256.0, 384.0, 128.0, 128.0)
drawing... (128.0, 512.0, 128.0, 128.0)
drawing... (512.0, 256.0, 128.0, 128.0)
drawing... (384.0, 384.0, 128.0, 128.0)
drawing... (-128.0, 512.0, 128.0, 128.0)
drawing... (0.0, 384.0, 128.0, 128.0)
drawing... (512.0, 512.0, 128.0, 128.0)
drawing... (256.0, 256.0, 128.0, 128.0)
drawing... (128.0, 384.0, 128.0, 128.0)
drawing... (-128.0, 256.0, 128.0, 128.0)
drawing... (-128.0, 128.0, 128.0, 128.0)
drawing... (0.0, 128.0, 128.0, 128.0)
drawing... (128.0, 128.0, 128.0, 128.0)
drawing... (256.0, 128.0, 128.0, 128.0)
drawing... (384.0, 128.0, 128.0, 128.0)
drawing... (512.0, 128.0, 128.0, 128.0)
drawing... (-128.0, 640.0, 128.0, 128.0)
drawing... (0.0, 640.0, 128.0, 128.0)
drawing... (128.0, 640.0, 128.0, 128.0)
drawing... (256.0, 640.0, 128.0, 128.0)
drawing... (384.0, 640.0, 128.0, 128.0)
drawing... (512.0, 640.0, 128.0, 128.0)
drawing... (-250.0, 128.0, 122.0, 128.0)
drawing... (-250.0, 256.0, 122.0, 128.0)
drawing... (-250.0, 384.0, 122.0, 128.0)
drawing... (-250.0, 512.0, 122.0, 128.0)
drawing... (-250.0, 640.0, 122.0, 128.0)
drawing... (640.0, 128.0, 110.0, 128.0)
drawing... (640.0, 256.0, 110.0, 128.0)
drawing... (640.0, 384.0, 110.0, 128.0)
drawing... (640.0, 512.0, 110.0, 128.0)
drawing... (640.0, 640.0, 110.0, 128.0)
drawing... (-250.0, 0.0, 122.0, 128.0)
drawing... (-128.0, 0.0, 128.0, 128.0)
drawing... (0.0, 0.0, 128.0, 128.0)
drawing... (128.0, 0.0, 128.0, 128.0)
drawing... (256.0, 0.0, 128.0, 128.0)
drawing... (384.0, 0.0, 128.0, 128.0)
drawing... (512.0, 0.0, 128.0, 128.0)
drawing... (640.0, 0.0, 110.0, 128.0)
drawing... (-250.0, 768.0, 122.0, 128.0)
drawing... (-128.0, 768.0, 128.0, 128.0)
drawing... (0.0, 768.0, 128.0, 128.0)
drawing... (128.0, 768.0, 128.0, 128.0)
drawing... (256.0, 768.0, 128.0, 128.0)
drawing... (384.0, 768.0, 128.0, 128.0)
drawing... (512.0, 768.0, 128.0, 128.0)
drawing... (640.0, 768.0, 110.0, 128.0)
drawing... (-250.0, -128.0, 122.0, 128.0)
drawing... (-128.0, -128.0, 128.0, 128.0)
drawing... (0.0, -128.0, 128.0, 128.0)
drawing... (128.0, -128.0, 128.0, 128.0)
drawing... (256.0, -128.0, 128.0, 128.0)
drawing... (384.0, -128.0, 128.0, 128.0)
drawing... (512.0, -128.0, 128.0, 128.0)
drawing... (640.0, -128.0, 110.0, 128.0)
drawing... (-250.0, 896.0, 122.0, 128.0)
drawing... (-128.0, 896.0, 128.0, 128.0)
drawing... (0.0, 896.0, 128.0, 128.0)
drawing... (128.0, 896.0, 128.0, 128.0)
drawing... (256.0, 896.0, 128.0, 128.0)
drawing... (384.0, 896.0, 128.0, 128.0)
drawing... (512.0, 896.0, 128.0, 128.0)
drawing... (640.0, 896.0, 110.0, 128.0)
drawing... (-250.0, -256.0, 122.0, 128.0)
drawing... (-128.0, -256.0, 128.0, 128.0)
drawing... (0.0, -256.0, 128.0, 128.0)
drawing... (128.0, -256.0, 128.0, 128.0)
drawing... (256.0, -256.0, 128.0, 128.0)
drawing... (384.0, -256.0, 128.0, 128.0)
drawing... (512.0, -256.0, 128.0, 128.0)
drawing... (640.0, -256.0, 110.0, 128.0)
drawing... (-250.0, 1024.0, 122.0, 128.0)
drawing... (-128.0, 1024.0, 128.0, 128.0)
drawing... (0.0, 1024.0, 128.0, 128.0)
drawing... (128.0, 1024.0, 128.0, 128.0)
drawing... (256.0, 1024.0, 128.0, 128.0)
drawing... (384.0, 1024.0, 128.0, 128.0)
drawing... (512.0, 1024.0, 128.0, 128.0)
drawing... (640.0, 1024.0, 110.0, 128.0)
drawing... (-250.0, -384.0, 122.0, 128.0)
drawing... (-128.0, -384.0, 128.0, 128.0)
drawing... (0.0, -384.0, 128.0, 128.0)
drawing... (128.0, -384.0, 128.0, 128.0)
drawing... (256.0, -384.0, 128.0, 128.0)
drawing... (384.0, -384.0, 128.0, 128.0)
drawing... (512.0, -384.0, 128.0, 128.0)
drawing... (640.0, -384.0, 110.0, 128.0)
drawing... (-250.0, 1152.0, 122.0, 128.0)
drawing... (-128.0, 1152.0, 128.0, 128.0)
drawing... (0.0, 1152.0, 128.0, 128.0)
drawing... (128.0, 1152.0, 128.0, 128.0)
drawing... (256.0, 1152.0, 128.0, 128.0)
drawing... (384.0, 1152.0, 128.0, 128.0)
drawing... (512.0, 1152.0, 128.0, 128.0)
drawing... (640.0, 1152.0, 110.0, 128.0)

如果我设置magnification = 10.0,则(1000%)-draw会被多次,多次调用。

是否有某种方法可以避免它?

我在我的应用中检查了所有-needsDisplay,并且我确定他们不对此行为负责。

0 个答案:

没有答案