【问题标题】:CATiledLayer and thread safetyCATiledLayer 和线程安全
【发布时间】: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

但似乎说问题现在已解决。好像不是这样的。

那么我的问题是:

  1. 还有哪些线程安全问题?
  2. 如果我需要使用drawLayerInContext,我如何确定绘图矩形是什么? (上面的 except 省略了根据矩形选择要绘制的图像的代码)。
  3. 如果我改用 Core Graphics 进行绘图,我需要添加什么额外的变换来使图像方向正确?

【问题讨论】:

    标签: ios core-graphics catiledlayer


    【解决方案1】:

    答案是 CATiledLayer 绘图不是线程安全的。您只能使用核心图形功能。没有任何 UI。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-09
      • 2014-03-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多