【发布时间】:2015-02-09 10:06:44
【问题描述】:
我最近从 Carbon 32bit 切换到 Cocoa 64bit。
使用 ctrl-MouseWheel 放大和缩小时,我的窗口出现白色闪烁。此外,图形性能低。
在 Carbon 中,我获得了我的图形上下文
CGrafPtr port = GetWindowPort(window);
QDBeginCGContext(port, &contextRef);
对于 Cocoa,我使用
CGContextRef myContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
在drawRect 方法中。
另外我设置了一个 25 fps 的计时器:
runLoopTimerRef = CFRunLoopTimerCreate(...);
CFRunLoopAddTimer(CFRunLoopGetCurrent(), runLoopTimerRef, kCFRunLoopCommonModes);
用于通过setNeedsDisplay:YES 重复绘制。我每次都需要重绘整个内容。
几乎所有的绘图都是用 CoreGraphics 完成的(CGContext...调用等等)。
与 Carbon 相比,Cocoa 的东西真的很慢(对鼠标点击的反应延迟)。
当我设置时
[self setOpaque:YES];
在我的drawRect 方法中,闪烁颜色变为黑色而不是白色。
没有层或后台缓冲区。
知道可能出了什么问题吗?我的drawRect 方法中缺少一些设置/状态调用?
【问题讨论】:
标签: macos cocoa core-graphics