繁体   English   中英

CATiledLayer和线程安全

[英]CATiledLayer and thread safety

我正在测试使用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

但似乎表示问题已解决。 似乎并非如此。

我的问题是:

  1. 仍然存在哪些线程安全问题?
  2. 如果需要使用drawLayerInContext,如何确定绘图矩形是什么? (上面的例外省略了代码以根据矩形选择要绘制的图像)。
  3. 如果我转为使用Core Graphics进行绘图,则需要添加其他哪些转换以使图像方向正确?

答案是CATiledLayer绘图不是线程安全的。 您只需要使用Core Graphics功能。 没有用户界面。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM