4

我想找到一种方法来替换 CALayer 函数 "layer.render(in: context)" ,这样可以更有效

if let context = CGContext(data: pixelData, width: Int(contextSize.width), height: Int(contextSize.height), bitsPerComponent: 8, bytesPerRow: CVPixelBufferGetBytesPerRow(pixelBuffer), space: rgbColorSpace, bitmapInfo: CGImageAlphaInfo.noneSkipFirst.rawValue) {
    let contentRect = CGRect(x: 0.0, y: 0.0, width: contextSize.width, height: contextSize.height)
    context.clear(contentRect)
    let flipVertical = CGAffineTransform.init(a: 1, b: 0, c: 0, d: -1, tx: 0, ty: contextSize.height)
    context.concatenate(flipVertical)
    // draw the layer in the context
    if let layer = self.delegate?.viedeoLayer?(atTime: Double(currentFrameCount)/Double(frameRate)) {
         //here is the Problem point
         layer.render(in: context)
    }            
   // unlock the buffer memory
   CVPixelBufferUnlockBaseAddress(pixelBuffer, CVPixelBufferLockFlags(rawValue: CVOptionFlags(0)))
}
4

0 回答 0