【发布时间】:2014-04-09 21:36:52
【问题描述】:
我正在测试使用 CATiledLayer 来绘制图像,它似乎比使用默认图层快得多(奇怪),即使发生了更多的绘图操作
在 drawRect 我有:
CGContextRef context = UIGraphicsGetCurrentContext () ;
CGContextSaveGState (context) ;
CGContextTranslateCTM (context, referencePoint.x, referencePoint.y) ;
CGContextScaleCTM(context, zoom * pixelScalingX / SCALE, zoom * pixelScalingY / SCALE) ;
CGContextRotateCTM (context, displayRotation) ;
CGPoint point = CGPointMake(displayCorner.x, displayCorner.y) ;
UIImage *image = [self getChartImage] ;
[image drawAtPoint:point] ;
CGContextRestoreGState(context) ;
我遇到的问题是在 [image drawAtPoint] 发生不可预测的访问冲突崩溃。
这向我暗示了一个线程安全问题。
本文提到线程安全
https://developer.apple.com/library/ios/qa/qa1637/_index.html
但似乎说问题现在已解决。好像不是这样的。
那么我的问题是:
- 还有哪些线程安全问题?
- 如果我需要使用drawLayerInContext,我如何确定绘图矩形是什么? (上面的 except 省略了根据矩形选择要绘制的图像的代码)。
- 如果我改用 Core Graphics 进行绘图,我需要添加什么额外的变换来使图像方向正确?
【问题讨论】:
标签: ios core-graphics catiledlayer