だから、私は'sメソッドCIImage
で描画しようとしているものがあります。NSView
-drawRect
これは、画像を描画するために呼び出すコード行です。
[outputCoreImage drawInRect: [self bounds]
fromRect: originalBounds
operation: NSCompositeSourceOver
fraction: 1];
outputCoreImage
、、、originalBounds
および[self bounds]
はすべて非nil
であり、実際にはそれぞれの期待値です。Lion(OS X 10.7)では、これは問題なく機能しましたが、Mountain Lion(OS X 10.8)ではEXC_BAD_ACCESS
、この回線でを受け取ります。スタックを上に行くと、壊れた内部関数呼び出しがオンになっていることがわかりますCGLGetPixelFormat
。
frame #0: 0x00007fff99c3b26d OpenGL`CGLGetPixelFormat + 27
frame #1: 0x00007fff8fa98978 CoreImage`-[CIOpenGLContextImpl createAccelContext] + 335
frame #2: 0x00007fff8fa98d30 CoreImage`-[CIOpenGLContextImpl updateContext] + 111
frame #3: 0x00007fff8fa9a865 CoreImage`-[CIOpenGLContextImpl _lockfeContext] + 25
frame #4: 0x00007fff8fa7e4ac CoreImage`-[CIContextImpl setObject:forKey:] + 120
frame #5: 0x00007fff8fa9881c CoreImage`-[CIOpenGLContextImpl setObject:forKey:] + 259
frame #6: 0x00007fff90db93e3 libCGXCoreImage.A.dylib`cgxcoreimage_instance_render + 1477
frame #7: 0x00007fff97074ac6 CoreGraphics`CGSCoreImageInstanceRender + 32
frame #8: 0x00007fff947c89cc libRIP.A.dylib`ripc_AcquireCoreImage + 1344
frame #9: 0x00007fff947b8a00 libRIP.A.dylib`ripc_DrawShading + 9680
frame #10: 0x00007fff96cb2b2b CoreGraphics`CGContextDrawShading + 51
frame #11: 0x00007fff8fa78237 CoreImage`-[CICGContextImpl render:] + 918
frame #12: 0x00007fff8fa7d76a CoreImage`-[CIContext drawImage:inRect:fromRect:] + 1855
frame #13: 0x00007fff9897b8f3 AppKit`-[CIImage(NSAppKitAdditions) drawInRect:fromRect:operation:fraction:] + 243
ゾンビ、ガードmalloc、ログ例外がすべてオンになっていますが、いずれも有用な情報を返しません。
その他のOpenGLテスト:
このチャンクを追加しました:
CIImage *anImage = [[CIImage alloc] init];
[[[self window] contentView] lockFocus];
{
[anImage drawInRect: [[self window] frame]
fromRect: [[self window] frame]
operation: NSCompositeSourceOver
fraction: 1];
}
[[[self window] contentView] unlockFocus];
私の-windowDidLoad
方法にNSWindowController
。問題なく動作します。
このチャンクを追加しました:
NSData *data = [NSData dataWithContentsOfURL: [NSURL URLWithString: @"http://cache.virtualtourist.com/14/684723-Red_Square_Moscow.jpg"]];
CIImage *anImage = [[CIImage alloc] initWithData: data];
[self lockFocus];
{
[anImage drawInRect: [self bounds]
fromRect: [anImage extent]
operation: NSCompositeSourceOver
fraction: 1];
}
[self unlockFocus];
別NSView
の'sに-drawRect
。で同じエラーが発生しましたCGLGetPixelFormat
。
レーダー:
#macdevにいる人々は、これはOSの問題であると信じているようで、私は反対する傾向はありません。問題を説明し、この質問にリンクするレーダー(rdar:// 11980704)を提出しました。
回避策:
CGContextRef contextReference = [[NSGraphicsContext currentContext] graphicsPort];
CIContext *coreImageContext = [CIContext contextWithCGContext: contextReference
options: @{kCIContextUseSoftwareRenderer : @YES}];
[coreImageContext drawImage: outputCoreImage
inRect: [self bounds]
fromRect: originalBounds];
ソフトウェアレンダラーを使用して画像を強制的に描画するように見えますが、問題は「解決」されます。少しぼやけて遅いですが、クラッシュしません。